home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Environments / Oberon⁄F™ 1.2 / Preinstalled version / Form / Mod / Models / Models (.txt)
Encoding:
Oberon Document  |  1996-07-08  |  18.4 KB  |  564 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. Helvetica
  17. StdStamps.StdViewDesc
  18. Helvetica
  19. Geneva
  20. MODULE FormModels;
  21. (** OmInc 
  22.     IMPORT Domains, Ports, Stores, Models, Views, Properties, Containers;
  23.     CONST
  24.         minViewSize* = 4 * Ports.point;    (** size of smallest embedded view **)
  25.         maxViewSize* = 1000 * Ports.mm;    (** size of largest embedded view **)
  26.         (* range of currently supported versions *)
  27.         minVersion = 0; maxBaseVersion = 0; maxStdVersion = 0;
  28.     TYPE
  29.         (* interface types *)
  30.         Model* = POINTER TO ModelDesc;
  31.         ModelDesc* = RECORD (Containers.ModelDesc) END;
  32.         Directory* = POINTER TO DirectoryDesc;
  33.         DirectoryDesc* = RECORD END;
  34.         Context* = POINTER TO ContextDesc;
  35.         ContextDesc* = RECORD (Models.ContextDesc) END;
  36.         Reader* = POINTER TO ReaderDesc;
  37.         ReaderDesc* = RECORD
  38.             view*: Views.View;    (** most recently read view **)
  39.             l*, t*, r*, b*: LONGINT    (** bounding box of most recently read view **)
  40.         END;
  41.         Writer* = POINTER TO WriterDesc;
  42.         WriterDesc* = RECORD END;
  43.         UpdateMsg* = RECORD (Models.UpdateMsg)
  44.             (** the receiver of this message must not switch on any marks **)
  45.             l*, t*, r*, b*: LONGINT    (** (l < r) & (b < t) **)
  46.         END;
  47.         (* concrete types *)
  48.         StdModel = POINTER TO StdModelDesc;
  49.         StdContext = POINTER TO StdContextDesc;
  50.         StdModelDesc = RECORD (ModelDesc)
  51.             contexts: StdContext    (* list of views in form, ordered from bottom to top *)
  52.         END;
  53.         StdDirectory = POINTER TO StdDirectoryDesc;
  54.         StdDirectoryDesc = RECORD (DirectoryDesc) END;
  55.         StdContextDesc = RECORD (ContextDesc)
  56.             next: StdContext;    (* next upper view *)
  57.             form: StdModel;    (* form # NIL *)
  58.             view: Views.View;    (* view # NIL *)
  59.             l, t, r, b: LONGINT    (* (r - l >= minViewSize) & (b - t >= minViewSize) *)
  60.         END;
  61.         StdReader = POINTER TO StdReaderDesc;
  62.         StdReaderDesc = RECORD (ReaderDesc)
  63.             form: StdModel;    (* form # NIL *)
  64.             pos: StdContext    (* next ReadView: read view above pos *)
  65.         END;
  66.         StdWriter = POINTER TO StdWriterDesc;
  67.         StdWriterDesc = RECORD (WriterDesc)
  68.             form: StdModel;    (* form # NIL *)
  69.             pos: StdContext    (* next WriteView: insert view above pos *)
  70.         END;
  71.         FormOp = POINTER TO FormOpDesc;
  72.         FormOpDesc = RECORD (Domains.OperationDesc)
  73.             del, ins: StdContext;    (* ((del = NIL) # (ins = NIL)) OR (del = ins) *)
  74.             pos: StdContext    (* ins # NIL => next Do: insert ins above pos *)
  75.         END;
  76.         ResizeOp = POINTER TO ResizeOpDesc;
  77.         ResizeOpDesc = RECORD (Domains.OperationDesc)
  78.             context: StdContext;    (* context # NIL *)
  79.             l, t, r, b: LONGINT    (* (r - l >= minViewSize) & (b - t >= minViewSize) *)
  80.         END;
  81.         ReplaceViewOp = POINTER TO ReplaceViewDesc;
  82.         ReplaceViewDesc = RECORD (Domains.OperationDesc)
  83.             context: StdContext;    (* context # NIL *)
  84.             view: Views.View    (* view # NIL *)
  85.         END;
  86.     VAR dir-, stdDir-: Directory;    (** (dir # NIL) & (stdDir # NIL) **)
  87.     (** Model **)
  88.     PROCEDURE (f: Model) Internalize* (VAR rd: Stores.Reader);
  89.         VAR thisVersion: SHORTINT;
  90.     BEGIN
  91.         f.Internalize^(rd);
  92.         IF rd.cancelled THEN RETURN END;
  93.         rd.ReadVersion(minVersion, maxBaseVersion, thisVersion)
  94.     END Internalize;
  95.     PROCEDURE (f: Model) Externalize* (VAR wr: Stores.Writer);
  96.     BEGIN
  97.         f.Externalize^(wr);
  98.         wr.WriteVersion(maxBaseVersion)
  99.     END Externalize;
  100.     PROCEDURE (f: Model) GetEmbeddingLimits* (VAR minW, maxW, minH, maxH: LONGINT);
  101.     BEGIN
  102.         minH := minViewSize; minW := minViewSize;
  103.         maxH := maxViewSize; maxW := maxViewSize
  104.     END GetEmbeddingLimits;
  105.     PROCEDURE (f: Model) Insert* (v: Views.View; l, t, r, b: LONGINT);
  106.         v # NIL    20
  107.         v.init    21
  108.         v.context = NIL    22
  109.         l <= r    23
  110.         t <= b    24
  111.     BEGIN
  112.         HALT(127)
  113.     END Insert;
  114.     PROCEDURE (f: Model) Delete* (v: Views.View);
  115.     (** v in f    20 **)
  116.     BEGIN
  117.         HALT(127)
  118.     END Delete;
  119.     PROCEDURE (f: Model) Resize* (v: Views.View; l, t, r, b: LONGINT);
  120.         v in f    20
  121.         l <= r    21
  122.         t <= b    22
  123.     BEGIN
  124.         HALT(127)
  125.     END Resize;
  126.     PROCEDURE (f: Model) PutAbove* (v, pos: Views.View);
  127.         v in f    20
  128.         (pos = NIL) OR (pos in f)    21
  129.     BEGIN
  130.         HALT(127)
  131.     END PutAbove;
  132.     PROCEDURE (f: Model) Move* (v: Views.View; dx, dy: LONGINT);
  133.     (** v in f    20 **)
  134.     BEGIN
  135.         HALT(127)
  136.     END Move;
  137.     PROCEDURE (f: Model) Copy* (VAR v: Views.View; dx, dy: LONGINT);
  138.     (** v in f    20 **)
  139.     BEGIN
  140.         HALT(127)
  141.     END Copy;
  142.     PROCEDURE (f: Model) NewReader* (old: Reader): Reader;
  143.     BEGIN
  144.         HALT(127)
  145.     END NewReader;
  146.     PROCEDURE (f: Model) NewWriter* (old: Writer): Writer;
  147.     BEGIN
  148.         HALT(127)
  149.     END NewWriter;
  150.     PROCEDURE (f: Model) ViewAt* (x, y: LONGINT): Views.View;
  151.     BEGIN
  152.         HALT(127)
  153.     END ViewAt;
  154.     PROCEDURE (f: Model) NofViews* (): INTEGER;
  155.     BEGIN
  156.         HALT(127)
  157.     END NofViews;
  158.     (** Directory **)
  159.     PROCEDURE (d: Directory) New* (): Model;
  160.     BEGIN
  161.         HALT(127)
  162.     END New;
  163.     (** Context **)
  164.     PROCEDURE (c: Context) ThisModel* (): Model;
  165.     BEGIN
  166.         RETURN NIL
  167.     END ThisModel;
  168.     PROCEDURE (c: Context) GetRect* (VAR l, t, r, b: LONGINT);
  169.     BEGIN
  170.         HALT(127)
  171.     END GetRect;
  172.     (** Reader **)
  173.     PROCEDURE (r: Reader) Set* (pos: Views.View);
  174.     (** (pos = NIL) OR (pos in r's form)    20 **)
  175.     BEGIN
  176.         HALT(127)
  177.     END Set;
  178.     PROCEDURE (r: Reader) ReadView* (VAR v: Views.View);
  179.     BEGIN
  180.         HALT(127)
  181.     END ReadView;
  182.     (** Writer **)
  183.     PROCEDURE (w: Writer) Set* (pos: Views.View);
  184.     (** (pos = NIL) OR (pos in w's form)    20 **)
  185.     BEGIN
  186.         HALT(127)
  187.     END Set;
  188.     PROCEDURE (w: Writer) WriteView* (v: Views.View; l, t, r, b: LONGINT);
  189.         v # NIL    20
  190.         v.init    21
  191.         v.context = NIL    22
  192.         l <= r    23
  193.         t <= b    24
  194.     BEGIN
  195.         HALT(127)
  196.     END WriteView;
  197.     (* StdModel *)
  198.     PROCEDURE ThisContext (f: StdModel; view: Views.View): StdContext;
  199.         VAR c: StdContext;
  200.     BEGIN
  201.         c := f.contexts; WHILE (c # NIL) & (c.view # view) DO c := c.next END;
  202.         RETURN c
  203.     END ThisContext;
  204.     PROCEDURE NewContext (form: StdModel; view: Views.View; l, t, r, b: LONGINT): StdContext;
  205.         VAR c: StdContext;
  206.     BEGIN
  207.         ASSERT(form # NIL, 20); ASSERT(view.context = NIL, 21);
  208.         IF r - l < minViewSize THEN r := l + minViewSize END;
  209.         IF b - t < minViewSize THEN b := t + minViewSize END;
  210.         NEW(c); c.form := form; c.view := view; c.l := l; c.t := t; c.r := r; c.b := b;
  211.         view.InitContext(c);
  212.         RETURN c
  213.     END NewContext;
  214.     PROCEDURE InsertAbove (c, pos: StdContext);
  215.     BEGIN
  216.         IF pos = NIL THEN
  217.             c.next := NIL; c.form.contexts := c
  218.         ELSE
  219.             c.next := pos.next; pos.next := c
  220.         END
  221.     END InsertAbove;
  222.     PROCEDURE (f: StdModel) Internalize (VAR rd: Stores.Reader);
  223.         VAR thisVersion: SHORTINT; top, h: StdContext; v: Views.View; l, t, r, b: LONGINT;
  224.     BEGIN
  225.         f.Internalize^(rd);
  226.         IF ~rd.cancelled THEN
  227.             rd.ReadVersion(minVersion, maxStdVersion, thisVersion);
  228.             IF ~rd.cancelled THEN
  229.                 Views.ReadView(rd, v); top := NIL;
  230.                 WHILE v # NIL DO
  231.                     rd.ReadLInt(l); rd.ReadLInt(t); rd.ReadLInt(r); rd.ReadLInt(b);
  232.                     h := NewContext(f, v, l, t, r, b);
  233.                     InsertAbove(h, top); top := h;
  234.                     Views.ReadView(rd, v)
  235.                 END
  236.             END
  237.         END
  238.     END Internalize;
  239.     PROCEDURE (f: StdModel) Externalize (VAR wr: Stores.Writer);
  240.         VAR c: StdContext; p: Properties.StorePref;
  241.     BEGIN
  242.         f.Externalize^(wr);
  243.         wr.WriteVersion(maxStdVersion);
  244.         c := f.contexts;
  245.         WHILE c # NIL DO
  246.             p.view := c.view; Views.HandlePropMsg(c.view, p);
  247.             IF p.view # NIL THEN    (* view is not temporary *)
  248.                 Views.WriteView(wr, p.view);
  249.                 wr.WriteLInt(c.l); wr.WriteLInt(c.t); wr.WriteLInt(c.r); wr.WriteLInt(c.b)
  250.             END;
  251.             c := c.next
  252.         END;
  253.         wr.WriteStore(NIL)
  254.     END Externalize;
  255.     PROCEDURE (f: StdModel) InitDomain (d: Domains.Domain);
  256.         VAR c: StdContext;
  257.     BEGIN    (* propagate domain to all embedded views *)
  258.         f.InitDomain^(d);
  259.         c := f.contexts; WHILE c # NIL DO c.view.InitDomain(d); c := c.next END
  260.     END InitDomain;
  261.     PROCEDURE (f: StdModel) CopyAllFrom (source: Models.Model);
  262.         VAR c, top, h: StdContext;
  263.     BEGIN
  264.         WITH source: StdModel DO
  265.             c := source.contexts; top := NIL;
  266.             WHILE c # NIL DO
  267.                 h := NewContext(f, Views.CopyOf(c.view, Views.deep), c.l, c.t, c.r, c.b);
  268.                 InsertAbove(h, top); top := h;
  269.                 c := c.next
  270.             END
  271.         END
  272.     END CopyAllFrom;
  273.     PROCEDURE (f: StdModel) InitFrom (source: Models.Model);
  274.     BEGIN
  275.         f.contexts := NIL
  276.     END InitFrom;
  277.     PROCEDURE (f: StdModel) ReplaceView (old, new: Views.View);
  278.         VAR op: ReplaceViewOp; c: StdContext;
  279.     BEGIN
  280.         c := ThisContext(f, old); ASSERT(c # NIL, 20);
  281.         ASSERT(new # NIL, 21); ASSERT((new.context = NIL) OR (new.context = c), 23);
  282.         IF old # new THEN
  283.             NEW(op); op.context := c; op.view := new;
  284.             Models.Do(f, "#System:ReplaceView", op)
  285.         END
  286.     END ReplaceView;
  287.     PROCEDURE (f: StdModel) Insert (v: Views.View; l, t, r, b: LONGINT);
  288.         VAR op: FormOp; c, h, top: StdContext;
  289.     BEGIN
  290.         ASSERT(v # NIL, 20); ASSERT(v.context = NIL, 22);
  291.         ASSERT(l <= r, 23); ASSERT(t <= b, 24);
  292.         h := f.contexts; top := NIL; WHILE h # NIL DO top := h; h := h.next END;
  293.         c := NewContext(f, v, l, t, r, b);
  294.         NEW(op); op.del := NIL; op.ins := c; op.pos := top;
  295.         Models.Do(f, "#System:Insertion", op)
  296.     END Insert;
  297.     PROCEDURE (f: StdModel) Delete (v: Views.View);
  298.         VAR op: FormOp; c: StdContext;
  299.     BEGIN
  300.         c := ThisContext(f, v); ASSERT(c # NIL, 20);
  301.         NEW(op); op.del := c; op.ins := NIL; op.pos := NIL;
  302.         Models.Do(f, "#System:Deletion", op)
  303.     END Delete;
  304.     PROCEDURE (f: StdModel) Resize (v: Views.View; l, t, r, b: LONGINT);
  305.         VAR op: ResizeOp; c: StdContext;
  306.     BEGIN
  307.         c := ThisContext(f, v); ASSERT(c # NIL, 20);
  308.         ASSERT(r >= l, 21); ASSERT(b >= t, 22);
  309.         IF r - l < minViewSize THEN r := l + minViewSize END;
  310.         IF b - t < minViewSize THEN b := t + minViewSize END;
  311.         NEW(op); op.context := c; op.l := l; op.t := t; op.r := r; op.b := b;
  312.         Models.Do(f, "#System:Resizing", op)
  313.     END Resize;
  314.     PROCEDURE (f: StdModel) PutAbove (v, pos: Views.View);
  315.         VAR op: FormOp; c, d: StdContext;
  316.     BEGIN
  317.         c := ThisContext(f, v); ASSERT(c # NIL, 20);
  318.         d := ThisContext(f, pos); ASSERT((pos = NIL) OR (d # NIL), 21);
  319.         IF v # pos THEN
  320.             NEW(op); op.del := c; op.ins := c; op.pos := d;
  321.             Models.Do(f, "#Form:ChangeZOrder", op)
  322.         END
  323.     END PutAbove;
  324.     PROCEDURE (f: StdModel) Move (v: Views.View; dx, dy: LONGINT);
  325.         VAR op: ResizeOp; c: StdContext;
  326.     BEGIN
  327.         c := ThisContext(f, v); ASSERT(c # NIL, 20);
  328.         IF (dx # 0) OR (dy # 0) THEN
  329.             NEW(op); op.context := c;
  330.             op.l := c.l + dx; op.t := c.t + dy; op.r := c.r + dx; op.b := c.b + dy;
  331.             Models.Do(f, "#System:Moving", op)
  332.         END
  333.     END Move;
  334.     PROCEDURE (f: StdModel) Copy (VAR v: Views.View; dx, dy: LONGINT);
  335.         VAR op: FormOp; c, h, top: StdContext;
  336.     BEGIN
  337.         c := ThisContext(f, v); ASSERT(c # NIL, 20);
  338.         h := f.contexts; top := NIL; WHILE h # NIL DO top := h; h := h.next END;
  339.         h := NewContext(f, Views.CopyOf(v, Views.deep), c.l + dx, c.t + dy, c.r + dx, c.b + dy);
  340.         NEW(op); op.del := NIL; op.ins := h; op.pos := top;
  341.         Models.Do(f, "#System:Copying", op);
  342.         v := h.view
  343.     END Copy;
  344.     PROCEDURE (f: StdModel) NewReader (old: Reader): Reader;
  345.         VAR r: StdReader;
  346.     BEGIN
  347.         IF (old = NIL) OR ~(old IS StdReader) THEN NEW(r) ELSE r := old(StdReader) END;
  348.         r.view := NIL; r.form := f; r.pos := NIL; RETURN r
  349.     END NewReader;
  350.     PROCEDURE (f: StdModel) NewWriter (old: Writer): Writer;
  351.         VAR w: StdWriter;
  352.     BEGIN
  353.         IF (old = NIL) OR ~(old IS StdWriter) THEN NEW(w) ELSE w := old(StdWriter) END;
  354.         w.form := f; w.pos := NIL; RETURN w
  355.     END NewWriter;
  356.     PROCEDURE (f: StdModel) ViewAt (x, y: LONGINT): Views.View;
  357.         VAR c, top: StdContext;
  358.     BEGIN
  359.         c := f.contexts; top := NIL;
  360.         WHILE c # NIL DO
  361.             IF (x >= c.l) & (y >= c.t) & (x < c.r) & (y < c.b) THEN top := c END;
  362.             c := c.next
  363.         END;
  364.         IF top = NIL THEN RETURN NIL ELSE RETURN top.view END
  365.     END ViewAt;
  366.     PROCEDURE (f: StdModel) NofViews (): INTEGER;
  367.         VAR c: StdContext; n: INTEGER;
  368.     BEGIN
  369.         n := 0; c := f.contexts; WHILE c # NIL DO INC(n); c := c.next END;
  370.         RETURN n
  371.     END NofViews;
  372.     (* StdContext *)
  373.     PROCEDURE (c: StdContext) ThisModel (): Model;
  374.     BEGIN
  375.         RETURN c.form
  376.     END ThisModel;
  377.     PROCEDURE (c: StdContext) GetSize (VAR w, h: LONGINT);
  378.     BEGIN
  379.         w := c.r - c.l; h := c.b - c.t
  380.     END GetSize;
  381.     PROCEDURE (c: StdContext) SetSize (w, h: LONGINT);
  382.         VAR w0, h0: LONGINT;
  383.     BEGIN
  384.         w0 := c.r - c.l; h0 := c.b - c.t; ASSERT(w0 > 0, 100); ASSERT(h0 > 0, 101);
  385.         Properties.PreferredSize(
  386.                 c.view, minViewSize, maxViewSize, minViewSize, maxViewSize, w0, h0, w, h);
  387.         IF (w # w0) OR (h # h0) THEN
  388.             c.form.Resize(c.view, c.l, c.t, c.l + w, c.t + h)
  389.         END
  390.     END SetSize;
  391.     PROCEDURE (c: StdContext) Normalize (): BOOLEAN;
  392.     BEGIN
  393.         RETURN FALSE
  394.     END Normalize;
  395.     PROCEDURE (c: StdContext) GetRect (VAR l, t, r, b: LONGINT);
  396.     BEGIN
  397.         l := c.l; t := c.t; r := c.r; b := c.b
  398.     END GetRect;
  399.     (* StdDirectory *)
  400.     PROCEDURE (d: StdDirectory) New (): Model;
  401.         VAR f: StdModel;
  402.     BEGIN
  403.         NEW(f); RETURN f
  404.     END New;
  405.     (* StdReader *)
  406.     PROCEDURE (r: StdReader) Set (pos: Views.View);
  407.         VAR c: StdContext;
  408.     BEGIN
  409.         IF pos = NIL THEN c := NIL ELSE c := ThisContext(r.form, pos); ASSERT(c # NIL, 20) END;
  410.         r.view := NIL; r.l := 0; r.t := 0; r.r := 0; r.b := 0;
  411.         r.pos := c
  412.     END Set;
  413.     PROCEDURE (r: StdReader) ReadView (VAR v: Views.View);
  414.         VAR c: StdContext;
  415.     BEGIN
  416.         c := r.pos;
  417.         IF c = NIL THEN c := r.form.contexts ELSE c := c.next END;
  418.         IF c # NIL THEN
  419.             r.view := c.view; r.l := c.l; r.t := c.t; r.r := c.r; r.b := c.b;
  420.             r.pos := c
  421.         ELSE
  422.             r.view := NIL; r.l := 0; r.t := 0; r.r := 0; r.b := 0
  423.         END;
  424.         v := r.view
  425.     END ReadView;
  426.     (* StdWriter *)
  427.     PROCEDURE (w: StdWriter) Set (pos: Views.View);
  428.         VAR c: StdContext;
  429.     BEGIN
  430.         IF pos = NIL THEN c := NIL ELSE c := ThisContext(w.form, pos); ASSERT(c # NIL, 20) END;
  431.         w.pos := c
  432.     END Set;
  433.     PROCEDURE (w: StdWriter) WriteView (v: Views.View; l, t, r, b: LONGINT);
  434.         VAR c: StdContext;
  435.     BEGIN
  436.         ASSERT(v # NIL, 20); ASSERT(v.context = NIL, 22);
  437.         ASSERT(l <= r, 23); ASSERT(t <= b, 24);
  438.         c := NewContext(w.form, v, l, t, r, b);
  439.         IF w.pos = NIL THEN
  440.             c.next := w.form.contexts; w.form.contexts := c
  441.         ELSE
  442.             c.next := w.pos.next; w.pos.next := c
  443.         END;
  444.         w.pos := c
  445.     END WriteView;
  446.     (* operations *)
  447.     PROCEDURE Update (c: StdContext);
  448.         VAR msg: UpdateMsg;
  449.     BEGIN
  450.         msg.l := c.l; msg.t := c.t; msg.r := c.r; msg.b := c.b; Models.Broadcast(c.form, msg)
  451.     END Update;
  452.     PROCEDURE (op: FormOp) Do;
  453.         VAR f: StdModel; c, p, pos: StdContext;
  454.     BEGIN
  455.         (* delete *)
  456.         pos := NIL;
  457.         c := op.del;
  458.         IF c # NIL THEN
  459.             f := c.form; ASSERT(f # NIL, 100);
  460.             p := f.contexts; ASSERT(p # NIL, 101);
  461.             IF p = c THEN
  462.                 f.contexts := c.next
  463.             ELSE
  464.                 WHILE p.next # c DO p := p.next; ASSERT(p # NIL, 102) END;
  465.                 pos := p; p.next := c.next
  466.             END;
  467.             c.next := NIL;
  468.             Update(c)
  469.         END;
  470.         (* insert *)
  471.         c := op.ins;
  472.         IF c # NIL THEN
  473.             f := c.form; ASSERT(f # NIL, 103);
  474.             p := f.contexts;
  475.             IF op.pos = NIL THEN
  476.                 c.next := f.contexts; f.contexts := c
  477.             ELSE
  478.                 c.next := op.pos.next; op.pos.next := c
  479.             END;
  480.             c.view.InitDomain(f.domain);
  481.             Update(c)
  482.         END;
  483.         (* swap ins and del for undo *)
  484.         p := op.del; op.del := op.ins; op.ins := p; op.pos := pos
  485.     END Do;
  486.     PROCEDURE (op: ResizeOp) Do;
  487.         VAR c: StdContext; l, t, r, b: LONGINT;
  488.     BEGIN
  489.         c := op.context;
  490.         (* save old state of context *)
  491.         l := c.l; t := c.t; r := c.r; b := c.b;
  492.         Update(c);
  493.         (* set new state of context *)
  494.         c.l := op.l; c.t := op.t; c.r := op.r; c.b := op.b;
  495.         Update(c);
  496.         (* old state is new undo state *)
  497.         op.l := l; op.t := t; op.r := r; op.b := b
  498.     END Do;
  499.     PROCEDURE (op: ReplaceViewOp) Do;
  500.         VAR c: StdContext; view: Views.View;
  501.     BEGIN
  502.         c := op.context;
  503.         (* save old state of context *)
  504.         view := c.view;
  505.         (* set new state of context *)
  506.         c.view := op.view; c.view.InitContext(c);
  507.         Update(c);
  508.         (* old state is new undo state *)
  509.         op.view := view
  510.     END Do;
  511.     (** miscellaneous **)
  512.     PROCEDURE New* (): Model;
  513.     BEGIN
  514.         RETURN dir.New()
  515.     END New;
  516.     PROCEDURE Clone* (source: Model): Model;
  517.         VAR st: Stores.Store; m: Model;
  518.     BEGIN
  519.         ASSERT(source # NIL, 20);
  520.         st := Stores.Clone(source); m := st(Model);
  521.         m.InitFrom(source);
  522.         RETURN m
  523.     END Clone;
  524.     PROCEDURE Copy* (source: Model): Model;
  525.         VAR st: Stores.Store; m: Model;
  526.     BEGIN
  527.         ASSERT(source # NIL, 20);
  528.         st := Stores.Clone(source); m := st(Model);
  529.         m.CopyAllFrom(source);
  530.         RETURN m
  531.     END Copy;
  532.     PROCEDURE GetRect* (v: Views.View; VAR l, t, r, b: LONGINT);
  533.         v # NIL    20
  534.         v.context # NIL    21
  535.         v.context IS Context    22
  536.     BEGIN
  537.         ASSERT(v # NIL, 20); ASSERT(v.context # NIL, 21); ASSERT(v.context IS Context, 22);
  538.         v.context(Context).GetRect(l, t, r, b)
  539.     END GetRect;
  540.     PROCEDURE SetDir* (d: Directory);
  541.     (** d # NIL    20 **)
  542.     BEGIN
  543.         ASSERT(d # NIL, 20); dir := d
  544.     END SetDir;
  545.     PROCEDURE Init;
  546.         VAR d: StdDirectory;
  547.     BEGIN
  548.         NEW(d); dir := d; stdDir := d
  549.     END Init;
  550. BEGIN
  551.     Init
  552. END FormModels.
  553. TextControllers.StdCtrlDesc
  554. TextControllers.ControllerDesc
  555. Containers.ControllerDesc
  556. Controllers.ControllerDesc
  557. TextRulers.StdRulerDesc
  558. TextRulers.RulerDesc
  559. TextRulers.StdStyleDesc
  560. TextRulers.StyleDesc
  561. TextRulers.AttributesDesc
  562. Helvetica
  563. Documents.ControllerDesc
  564.